#include "matrix.h"

namespace krryn{
namespace math{
	matrix matrix::create_perspective_projection(float a_Near, float a_Far, float a_Width, float a_Height){
		matrix m;

		m.cell[D0]		= (2 * a_Near) / a_Width;
		m.cell[D1]		= (2 * a_Near) / a_Height;
		m.cell[D2]		= (a_Far + a_Near) / (a_Far - a_Near);
		m.cell[D2 + 1]	= -((2 * a_Far * a_Near) / (a_Far - a_Near));
		m.cell[D3]		= 0;
		m.cell[D3 - 1]	= 1;

		return m;
	}

	std::ostream& operator<<(std::ostream& a_Stream, matrix &a_Matrix){
		for(int i = 0; i < 4; i++){
			if(i == 0){
				a_Stream << '[';
			}else{
				a_Stream << ' ';
			}

			a_Stream << '[';

			for(int j = 0; j < 4; j++){
				a_Stream << a_Matrix[j + i * 4];

				if(j != 3){
					a_Stream << ", ";
				}
			}

			a_Stream << ']';

			if(i == 3){
				a_Stream << ']';
			}

			a_Stream << std::endl;
		}

		return a_Stream;
	}
}
}